home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / os20 / wb / toolmanager2_0.lha / ToolManager / Source / prefs / window.c < prev   
C/C++ Source or Header  |  1992-09-26  |  3KB  |  100 lines

  1. /*
  2.  * window.c  V2.0
  3.  *
  4.  * safe window close function
  5.  *
  6.  * (c) 1990-1992 Stefan Becker
  7.  */
  8.  
  9. #include "ToolManagerConf.h"
  10.  
  11. /* Wait pointer image data */
  12. static __chip const UWORD WaitPointer[]={
  13.                                          0x0000, 0x0000,
  14.  
  15.                                          0x0400, 0x07c0,
  16.                                          0x0000, 0x07c0,
  17.                                          0x0100, 0x0380,
  18.                                          0x0000, 0x07e0,
  19.                                          0x07c0, 0x1ff8,
  20.                                          0x1ff0, 0x3fec,
  21.                                          0x3ff8, 0x7fde,
  22.                                          0x3ff8, 0x7fbe,
  23.                                          0x7ffc, 0xff7f,
  24.                                          0x7efc, 0xffff,
  25.                                          0x7ffc, 0xffff,
  26.                                          0x3ff8, 0x7ffe,
  27.                                          0x3ff8, 0x7ffe,
  28.                                          0x1ff0, 0x3ffc,
  29.                                          0x07c0, 0x1ff8,
  30.                                          0x0000, 0x07e0,
  31.  
  32.                                          0x0000, 0x0000
  33.                                         };
  34.  
  35. /* Close a window safely */
  36. void CloseWindowSafely(struct Window *w)
  37. {
  38.  struct IntuiMessage *msg;
  39.  
  40.  DEBUG_PRINTF("CloseWindowSafely: 0x%08lx\n",w);
  41.  
  42.  /* we forbid here to keep out of race conditions with Intuition */
  43.  Forbid();
  44.  
  45.  /* Remove all messsages for this window */
  46.  msg=GetHead(&w->UserPort->mp_MsgList);
  47.  while (msg)
  48.   /* Does this message point to the window? */
  49.   if (msg->IDCMPWindow==w) {
  50.    struct IntuiMessage *nextmsg=GetSucc(msg);
  51.  
  52.    /* Yes. Remove it from port */
  53.    Remove((struct Node *) msg);
  54.  
  55.    /* Reply it */
  56.    ReplyMsg((struct Message *) msg);
  57.  
  58.    /* Get pointer to next message */
  59.    msg=nextmsg;
  60.   }
  61.    /* No. Get pointer to next message */
  62.   else msg=GetSucc(msg);
  63.  
  64.  /* clear UserPort so Intuition will not free it */
  65.  w->UserPort=NULL;
  66.  
  67.  /* tell Intuition to stop sending more messages */
  68.  ModifyIDCMP(w,0);
  69.  
  70.  /* turn multitasking back on */
  71.  Permit();
  72.  
  73.  DEBUG_PRINTF("Closing window\n");
  74.  
  75.  /* and really close the window */
  76.  CloseWindow(w);
  77.  
  78.  DEBUG_PRINTF("Window closed\n");
  79. }
  80.  
  81. /* Disable a window */
  82. void DisableWindow(struct Window *w)
  83. {
  84.  /* Disable IDCMP */
  85.  ModifyIDCMP(w,IDCMP_REFRESHWINDOW);
  86.  
  87.  /* Set wait pointer */
  88.  SetPointer(w,WaitPointer,16,16,-6,0);
  89. }
  90.  
  91. /* Enable a window */
  92. void EnableWindow(struct Window *w, ULONG idcmp)
  93. {
  94.  /* Clear wait pointer */
  95.  ClearPointer(w);
  96.  
  97.  /* Enable IDCMP */
  98.  ModifyIDCMP(w,idcmp);
  99. }
  100.